Fix file descriptor leak in blktapctrl
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 1 Aug 2007 08:04:20 +0000 (09:04 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 1 Aug 2007 08:04:20 +0000 (09:04 +0100)
commit4eb73854d70f5fd252bb6b17b26a58ac3bfff6a4
treef4d3ce2123fc250e3eb0b255e09857d4dc6a43c3
parenta0bc2a22180ce4cfa6131116d4d1ccf51e0dbbcc
Fix file descriptor leak in blktapctrl

The blktapctrl process is responsible for spawning individual tapdisk
processes. It does this using the 'system' method, but unfortunately
none of its file descriptors have the close-on-exec flag set. The
parent blktapctl process opens a couple of unix domain sockets
per-tapdisk it spawns. So the first tapdisk get 2 FDs leaked to it,
the second gets 4 FDs leaked to it, the 3rd gets 6 and so on. The use
of 'system' also unneccessarily invokes the shell.

Replace system with fork/execvp, and explicitly close all file handles
up to _SC_OPEN_MAX.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
tools/blktap/drivers/blktapctrl.c